<template>
    <div class="body">
        <div class="hg_title">
            <div></div>
            <dl @click="turnBlank(1, { categoryId: '3402878414627119130' })">
                <dd>最新公告</dd>
                <dt>LATEST NEWS</dt>
            </dl>
            <div></div>
        </div>
        <div class="hg_newbox">
            <div class="hg_newboxlef">
                <Banner />
            </div>

            <div class="hg_newboxrig">
                <div
                    v-for="(item, index) in dataList"
                    :key="index"
                    @click="turnBlank(2, { typeId: item.typeId, id: item.id })"
                    class="hg_liclass"
                    :class="{ hg_active: index === icurli }"
                    @mouseover="icurli = index"
                    @mouseleave="icurli = 0"
                >
                    <div class="hg_boxchildtop">
                        <h1>
                            {{ item.name }}
                        </h1>
                        <h2>
                            <img
                                src="@/assets/img/hg/icon_time.png"
                                alt=""
                            /><span>{{ item.publishTime }}</span>
                        </h2>
                        <h3>
                            {{ item.cmsArticle.content }}
                        </h3>
                    </div>

                    <div class="hg_boxlist">
                        <a>
                            <i></i>
                            <span>{{ item.name }}</span>
                            <b>{{ item.publishTime }}</b>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import appUtil from '~/assets/utils/appUtil';
import { createNamespacedHelpers } from 'vuex';
import Banner from './Banner.vue';
const { mapActions } = createNamespacedHelpers('hgModule');
export default {
    components: { Banner },
    name: 'test',
    data() {
        return {
            dataList: [],
            icurli: 0,
            icur: '3402878414627119130',
            title: '最新公告',
        };
    },
    mounted() {
        this.getdataList(1, 4, this.icur);
    },
    methods: {
        ...mapActions(['getdataListsAsync']),
        turnBlank(type, Parameters) {
            appUtil.routerUrl(type, Parameters, this.title, this.icur);
        },
        getdataList(pn, ps, categoryId) {
            this.getdataListsAsync({
                pn,
                ps,
                categoryId,
            }).then((res) => {
                this.dataList = res.data.dataList;
                for (let i = 0; i < this.dataList.length; i++) {
                    if (this.dataList[i].cmsArticle) {
                        this.dataList[
                            i
                        ].cmsArticle.content = appUtil.strIntercept(
                            this.dataList[i].cmsArticle.content
                        );
                    }
                }
            });
        },
    },
};
</script>

<style lang="scss" scoped>
.body {
    width: 1200px;
    overflow: hidden;
    margin: 0 auto;
}
.hg_title {
    width: 100%;
    min-width: 1200px;
    height: 70px;
    margin: 20px auto 10px;

    div {
        width: 44%;
        height: 8px;
        background: #d8d8d8;
        border-radius: 2px;
        opacity: 0.3;
        float: left;
        margin-top: 18px;
    }

    dl {
        float: left;
        width: 12%;
        text-align: center;
        cursor: pointer;

        dd {
            font-size: 28px;
            font-weight: bold;
            color: #094194;
        }

        dt {
            font-size: 18px;
            font-weight: bold;
            color: #094194;
            opacity: 0.2;
            margin-top: -6px;
        }
    }
}

.hg_newbox {
    padding: 0 10px;

    .hg_newboxlef {
        width: 545px;
        height: 310px;
        float: left;
    }
    .hg_liclass {
        .hg_boxchildtop {
            display: none;
        }
        .hg_boxlist {
            display: block;
        }
    }
    .hg_newboxrig {
        margin-left: 565px;
        height: 310px;

        .hg_active {
            .hg_boxchildtop {
                display: block;
            }
            .hg_boxlist {
                display: none;
            }
        }

        .hg_boxchildtop {
            height: 168px;
            background: #f7f7f7;
            border-radius: 4px;
            padding: 0 20px;
            cursor: pointer;

            h1 {
                font-size: 26px;
                padding-top: 14px;
                font-weight: 600;
                color: #333333;
                line-height: 35px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                padding-right: 10px;
            }

            h2 {
                font-size: 12px;
                color: #aaa;
                font-weight: normal;
                height: 20px;
                line-height: 20px;
                margin: 11px auto;

                img {
                    float: left;
                    margin: 4px 5px 0 2px;
                }

                span {
                    float: left;
                }
            }

            h3 {
                font-size: 14px;
                font-weight: 400;
                color: #555555;
                line-height: 24px;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 3;
                overflow: hidden;

                a {
                    font-size: 10px;
                    font-weight: 400;
                    color: #094191;
                    line-height: 26px;
                    float: right;
                }
            }
        }

        .hg_boxlist {
            a {
                width: 100%;
                display: inline-block;
                border-bottom: 1px solid #eaeaea;
                height: 45px;
                line-height: 45px;
                cursor: pointer;

                i {
                    float: left;
                    width: 4px;
                    height: 4px;
                    background: #999999;
                    border-radius: 2px;
                    margin: 21px 10px 0 5px;
                }

                span {
                    float: left;
                    font-size: 14px;
                    font-weight: 400;
                    color: #333333;
                    max-width: 75%;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }

                b {
                    float: right;
                    font-size: 14px;
                    font-weight: 400;
                    color: #666666;
                    margin-right: 20px;
                }
            }
        }
    }
}
</style>
